//
//  User.m
//  MVPTableViewDemo
//
//  Created by 胡锦涛 on 2019/1/27.
//  Copyright © 2019 胡锦涛. All rights reserved.
//

#import "User.h"

@implementation User


+ (void)getUsers:(void(^)(NSArray<User*> *users))usersBlock {
    
    //获取数据
    NSArray * tempArray = @[@{@"name":@"Steven",@"imageUrl":@"http://cc",@"age":@"19"},
                            @{@"name":@"Bob",@"imageUrl":@"http://cc",@"age":@"18"},
                            @{@"name":@"Paul",@"imageUrl":@"http://cc",@"age":@"17"},
                            @{@"name":@"Lucy",@"imageUrl":@"http://cc",@"age":@"99"}];
    NSMutableArray<User*> *users = [NSMutableArray arrayWithCapacity:tempArray.count];
    
    for (int i = 0; i<tempArray.count; i++) {
        User * user = [[User alloc] init];
        [user setValuesForKeysWithDictionary:tempArray[i]];
        //添加数组
        [users addObject:user];
    }
    
    //GCD设置延迟
    double delay = 0.25;
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        if (usersBlock) {
            usersBlock(users);
        }
    });
    
}
@end
